package com.leyou.order.web;

import com.leyou.order.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@Slf4j
@RestController
@RequestMapping("/notify")
public class NotifyController {
    @Autowired
    private OrderService orderService;

    /**
     * 引入依赖<artifactId>jackson-dataformat-xml</artifactId> 接受微信传过来的xml
     * @param result
     * @return
     */
    @PostMapping(value = "/pay",produces = "application/xml")
    public Map hello(@RequestBody Map<String,String> result){
        //处理回调
        orderService.handlerNotify(result);
        log.info("微信支付回调,接受结果:{}", result);
        Map<String,String> map=new HashMap<>();
        map.put("return_code","SUCCESS");
        map.put("return_msg","OK");
        return map;
    }
}
